<script setup lang="ts">
import { ref } from 'vue'
import type { IRomInfo } from '@/types'

defineProps<{ item: IRomInfo }>()

const score = ref(4.5)

//鼠标移入显示截图
let isHover = ref(false)
</script>

<template>
  <el-card
    class="el-card"
    @mouseover="isHover = true"
    @mouseleave="isHover = false"
    :body-style="{ padding: '0' }"
  >
    <img
      :src="isHover ? item.image : item.cover"
      alt="cover"
      class="img"
      @click="$router.push({ path: '/play', query: { id: item.id } })"
    />
    <template #footer>
      <el-row justify="space-between">
        <span class="footer">{{ item.title }}</span>
        <el-rate
          style="margin: auto 0"
          v-model="score"
          show-score
          :colors="['#99A9BF', '#F7BA2A', '#FF9900']"
          text-color="#0099ff"
          score-template="{value}"
        />
      </el-row>
      <el-row justify="space-between">
        <span style="color: #999">{{ item.publisher }}</span>
        <el-tag>{{ item.category }}</el-tag>
      </el-row>
    </template>
  </el-card>
</template>

<style lang="scss" scoped>
.el-card {
  border-radius: 10px;
  .img {
    width: 100%;
    height: 270px;
  }
  .footer {
    font-size: 20px;
    width: 50%; /*一定要设置宽度，或者元素内含的百分比*/
    overflow: hidden; /*溢出的部分隐藏*/
    white-space: nowrap; /*文本不换行*/
    text-overflow: ellipsis; /*ellipsis:文本溢出显示省略号（...）；*/
  }
}
</style>
